package cn.xo68.boot.ui.entity;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

/**
 * require config
 * @author wuxie
 * @version 2019-3-20
 */
public class RequireConfig implements Serializable {

    public static final String BASE_URL_DEFAULT="./ui/";

    private String baseUrl=BASE_URL_DEFAULT;
    private Map<String,String> paths;

    private int waitSeconds=5;

    private List<String> deps;

    public RequireConfig() {
        paths= new LinkedHashMap<>();
        deps= new LinkedList<>();
    }

    public String getBaseUrl() {
        return baseUrl;
    }

    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }

    public Map<String, String> getPaths() {
        return paths;
    }

    public void setPaths(@NotNull Map<String, String> paths) {
        this.paths = paths;
    }

    public void addPath(RequirePathMapping requirePathMapping){
        this.paths.put(requirePathMapping.getModuleName(),requirePathMapping.getModulePath());
    }
    public void addPaths(List<RequirePathMapping> requirePathMappings){
        requirePathMappings.forEach(requirePathMapping -> {
            this.paths.put(requirePathMapping.getModuleName(),requirePathMapping.getModulePath());
        });
    }

    public int getWaitSeconds() {
        return waitSeconds;
    }

    public void setWaitSeconds(int waitSeconds) {
        this.waitSeconds = waitSeconds;
    }


    public List<String> getDeps() {
        return deps;
    }

    public void setDeps(List<String> deps) {
        this.deps = deps;
    }

    public void addDeps(String deps){
        this.deps.add(deps);
    }
    public void addDepsAll(List<String> depsList){
        this.deps.addAll(depsList);
    }
}
